class CreateBaseUsers < ActiveRecord::Migration[5.1]
  def change
    create_table :base_users do |t|
      t.string :name_cn, comment: '姓名'
      t.boolean :gender, comment: '性别'
      t.string :username, comment: '登陆名'
      t.string :password, comment: '登陆密码'
      t.boolean :active, comment: '是否在职', default: true
      t.integer :department_id, comment: '部门id'
      t.string :email, comment: '个人邮箱'
      t.string :mobile, comment: '个人手机'
      t.datetime :last_login_at, comment: '上次登陆时间'
      t.date :leave_time, comment: '离职时间'
      t.string :phone_ext, comment: '分机号'
      t.integer :customer_id, comment: '对应客户'

      t.timestamps
    end

    add_index :base_users, :name_cn
    add_index :base_users, :mobile
    add_index :base_users, :username
    add_index :base_users, :active
    add_index :base_users, :department_id
  end
end
